package com.example.jwtauthdemo.mapper;

import com.example.jwtauthdemo.dao.Student;
import com.example.jwtauthdemo.vo.StudentApplicationVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


import java.util.List;
@Mapper
public interface StudentManageMapper {
    //查看学生信息
     List<Student> selectStudentInfo(String classCode, String teacherId);
//AND EXISTS (SELECT 1 FROM (SELECT 1 FROM user_class_relation WHERE class_code = #{classCode} AND user_id = #{teacherId} AND role = 1) AS teacher_check)
    //移除学生
    @Delete("DELETE ucr FROM user_class_relation ucr WHERE ucr.class_code = #{classCode} AND ucr.user_id = #{studentId} ")
    int removeStudent(@Param("classCode") Integer classCode, @Param("studentId") Integer studentId, @Param("teacherId") Integer teacherId);

    //发送通知
    int sendNotice(String classCode, String notice);
    
    //同意学生加入班级
    int agreeStudent(@Param("classCode") Integer classCode, @Param("studentId") Integer studentId, @Param("role") Integer role);
    
    //查询待同意的学生申请并关联用户信息
    List<StudentApplicationVO> selectPendingStudentApplications(@Param("teacherId") Integer teacherId);
    
    //更新学生申请班级的状态（同意=1，拒绝=2）
    int updateStudentApplicationStatus(@Param("userId") Integer userId, @Param("status") Integer status);

    //教师申请加入班级
    int teacherApplyForClass(@Param("userId") Integer userId, @Param("classCode") Integer classCode, @Param("status") Integer status);
    
    //更新用户的班级ID
    int updateUserClassId(@Param("userId") Integer userId, @Param("classCode") Integer classCode);

    //查询已同意或拒绝的学生申请并关联用户信息
    List<StudentApplicationVO> selectApprovedApplications(@Param("teacherId") Integer teacherId);

}
